<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.List"%>
<%@ page import="javax.jdo.PersistenceManager"%>
<%@ page import="com.google.appengine.api.users.User"%>
<%@ page import="com.google.appengine.api.users.UserService"%>
<%@ page import="com.google.appengine.api.users.UserServiceFactory"%>
<%@ page import="myGuestbook.Greeting"%>
<%@ page import="myGuestbook.PMF"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>點數交換網</title>
<style>

    /* START - toptop menu */

ul#TTPM

{

    list-style: none;

    float: left;

    margin:0px;

    padding:0px;

}



ul#TTPM li ul {

    display: none;

}

ul#TTPM li

{

    list-style: none;

    font-weight:bold;

}

ul#TTPM li:hover > ul {

    display: block;

    position:absolute;

    z-index:500;

    padding:0px;

} 

/* END - toptop menu */

    </style>
<style type="text/css">

.tablein {
	font-size: 36px;
	color: #CCC;
	background-color: #000;
}

.tableins {
	font-size: 36px;
	color: #CCC;
	background-color: #000;
	color: #CC3333;
}



.title {
	font-size: 70px;
	font-weight: bolder;
	color: #000;
}
a {text-decoration: none;
	 color: #000;
} 

.tabletit {
	font-size: 36px;
	color: #000;
	border-top-color: #000;
	border-right-color: #000;
	border-bottom-color: #000;
	border-left-color: #000;
	text-decoration: none;
	text-align: center;
}
.tabletits {
	font-size: 36px;
	color: #FFFFFF;
	border-top-color: #000;
	border-right-color: #000;
	border-bottom-color: #000;
	border-left-color: #000;
	text-decoration: none;
	text-align: center;
}

body {
	background-color: #99C;
}

.tblCon {
	font-size: 16px;
	font-weight: bold;
	color: #000;
	text-decoration: none;
	text-align: center;
}

.new {
	color: #F06;
}
</style>
</head>

<body>
	<table width="1038" height="667" border="0" align="center">
  <tr>
    <th height="188" colspan="4" rowspan="2" class="title" scope="col">會員管理</th>
    <th width="208" height="188" scope="col">Welcome</th>
  </tr>
  <tr>
    <td><p><a href="index_un.jsp" class="accept">回首頁</a></p></td>
  </tr>
  <tr>
    <th colspan="4" scope="row">&nbsp;</th>
    <td>&nbsp;</td>
  </tr>
  <tr>
      <th width="202" height="133" bgcolor="#0066FF" class="tabletit" scope="row">
    <ul id="TTPM">

        <li id="TTPMI">我的活動

            <ul>

                <li><a href="StrtPg.jsp" ><span class="tablein">發起</span></a></li>

                <li><a href="Attend.jsp" ><span class="tablein">參與</span></a></li>


            </ul>

        </li>

    </ul></th>
    <th width="202" bgcolor="#CC66CC" scope="row"><a href="../record.jsp" class="tabletit" >交易紀錄</a></th>
    <th width="202" bgcolor="#FFFF33" scope="row"><a href="../MyInv.jsp" class="tabletit">我的邀請</a></th>
    <th width="202" bgcolor="#CC3333" class=" scope="row"><a href="../mesg.jsp" class="tabletits">留言</a></th>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <th height="21" colspan="5" bgcolor="#000000" scope="row">&nbsp;</th>
  </tr>
		<tr>
			<th height="53" colspan="4" scope="row">&nbsp;</th>
			<td colspan="2" bgcolor="#9999CC" class="tabletit">&nbsp;</td>
		</tr>
	</table>
	<%
		UserService userService = UserServiceFactory.getUserService();
		User user = userService.getCurrentUser();
		if (user != null) {
	%>
	<p>
		Hello,
		<%=user.getNickname()%>! (You can <a
			href="<%=userService.createLogoutURL(request.getRequestURI())%>">sign
			out</a>.)
	</p>
	<%
		} else {
	%>
	<p>
		Hello! <a
			href="<%=userService.createLoginURL(request.getRequestURI())%>">Sign
			in</a> to include your name with greetings you post.
	</p>
	<%
		}
	%>

	<%
		PersistenceManager pm = PMF.get().getPersistenceManager();
		String query = "select from " + Greeting.class.getName();
		List<Greeting> greetings = (List<Greeting>) pm.newQuery(query).execute();
		if (greetings.isEmpty()) {
	%>
	<p>The guestbook has no messages.</p>
	<%
		} else {
			for (Greeting g : greetings) {
				if (g.getAuthor() == null) {
	%>
	<p>
		An anonymous person wrote @<%=g.getDate()%>:
	</p>
	<%
		} else {
	%>
	<p>
		<b><%=g.getAuthor().getNickname()%></b> wrote:
	</p>
	<%
		}
	%>
	<blockquote><%=g.getContent()%></blockquote>
	<%
		}
		}
		pm.close();
	%>

	<form action="/sign" method="post">
		<div>
			<textarea name="content" rows="3" cols="60"></textarea>
		</div>
		<div>
			<input type="submit" value="Post Greeting" />
		</div>
	</form>

</body>
</html>